Skip to content

fix(ci): detect stale workflow-file drift before it silently no-ops the agent step - #255

Merged
libravault-xyz merged 1 commit into
devfrom
fix/agent-pipeline-workflow-drift-oidc
Aug 18, 2026
Merged

libravault-xyz merged 1 commit into
devfrom
fix/agent-pipeline-workflow-drift-oidc

Conversation

@libravault-pipeline-bot

Copy link
Copy Markdown
Contributor

Summary

dev-agent.yml, qa-agent.yml, and principal-review.yml all use anthropics/claude-code-action with permissions: id-token: write on a pull_request-triggered job. GitHub's own anti-tampering check refuses to mint that OIDC token whenever the running workflow's own file on the PR branch doesn't byte-match the copy on dev — this is GitHub protecting against a PR modifying the very workflow that's about to run with elevated trust. When that happens, the "Run agent" step itself still reports success in the Actions UI (the token exchange fails inside the action, not the step), so the agent silently never ran, and the workflow falls through to its generic "produced neither a verdict file nor a verdict comment line" message — which is misleading, since nothing actually ran, and sends a human down the wrong troubleshooting path (confirmed live on PR #234 in issue #254, first assumed to be an LLM/prompt bug).

Closes #254

Approach

Rather than the log-scraping approach the issue floats as a fallback (grep the job log for "Workflow validation failed" after the fact), this detects the condition proactively: right after each workflow checks out the PR branch — and before its agent step runs — a new step does:

git fetch origin dev
git diff --quiet origin/dev -- .github/workflows/<this-workflow>.yml

If that workflow's own file has drifted from dev, the agent step is skipped outright (via if: ... && steps.workflow-drift.outputs.drift != 'true'), and the "advance PR" step posts a distinct, actionable comment ("this PR's branch is stale relative to dev — rebase dev in and re-add the triggering label") instead of running a doomed OIDC exchange and reporting the old generic message. Routes to status:needs-info without consuming qa-agent.yml's auto-retry budget — this is a pipeline/tooling failure, not a real finding, matching how the existing crash-handling branches in each workflow already reason about the same distinction.

Applied to all three pipeline workflows since they share the identical claude-code-action + id-token: write + pull_request pattern (per the issue: "This isn't specific to qa-agent"):

  • qa-agent.yml — checked unconditionally (every run operates on an existing PR branch).
  • principal-review.yml — same, unconditionally.
  • dev-agent.yml — scoped to revise mode only (steps.guard.outputs.mode == 'revise'). Triage mode never checks out a PR branch before its own agent step (it runs from the default branch checkout), so its own copy of dev-agent.yml is already dev's copy — the drift condition can't occur there.

I deliberately did not implement the issue's other suggested option (a rebase-before-agent self-heal step) or touch PR #234 itself — the issue explicitly frames the immediate unblock (rebasing #234) as a separate human decision, and a full self-heal-by-rebase adds real complexity (force-push semantics, conflict handling) for a problem this simpler skip-and-report fix already resolves at the "stop misleading humans" level the issue's root complaint is about.

Risk

This diff touches .github/workflows/**, one of agent-policy.yml's sensitive_paths — classify_pr_risk.py will force risk:high on this PR regardless of QA/review outcome, so it always lands on status:needs-human-merge, never auto-merged. Flagging explicitly per the dev-agent persona's instructions.

The new steps only run git fetch/git diff (no gh calls, no token needed beyond what actions/checkout already persists) — low blast radius. Worst case of a bug in the new check is a false skip (an agent run that would have worked gets skipped and routed to status:needs-info instead) — recoverable by a human re-applying the triggering label, same recovery path the pre-existing malfunction/crash branches already rely on.

Testing

No JVM/Kotlin code is touched, so ./gradlew testDebugUnitTest is not relevant here (nothing in that suite exercises workflow YAML). Validated:

  • All three modified workflow files parse as valid YAML (yaml.safe_load).
  • Traced the new if: conditions and GitHub Actions' implicit-success() semantics by hand to confirm the new step composes correctly with each workflow's existing skip/crash/verdict branches (in particular, that referencing an unset step output like steps.workflow-drift.outputs.drift when that step didn't run — dev-agent.yml triage mode — evaluates to empty string, not an error, so the agent step still runs normally in that mode).
  • There's no existing test harness for these workflows' inline run: blocks (only .github/scripts/*.sh gets test_resolve_linked_issue.sh-style shell tests) — this pipeline's own workflow logic has historically been validated live, per the "confirmed live" write-ups throughout docs/agent-team-pipeline.md and the other workflow files' comments. I could not exercise this change against a real stale-branch PR without creating one.

…he agent step

GitHub refuses to mint the OIDC token claude-code-action needs
(id-token: write, pull_request-triggered) whenever the running
workflow's own file on the PR branch doesn't byte-match dev's copy —
its own anti-tampering check. The agent step still reports success
when this happens (the token exchange fails inside the action, not
the step), so a stale PR branch touching one of these three workflow
files silently produces no verdict at all, and the fallback logic
reports a misleading generic message ("produced neither a verdict
file nor a verdict comment line") that sends humans down the wrong
troubleshooting path.

Live-hit on PR #234 (issue #254): 14 commits behind dev, with
qa-agent.yml among 7 diverged workflow files, failed identically
twice.

Add a preemptive git-diff check (against dev) of each workflow's own
file, right after the PR branch is checked out and before its agent
step runs. On drift, skip the agent step and post a distinct,
actionable comment ("this PR's branch is stale relative to dev —
rebase and retry") instead of running a doomed OIDC exchange and
falling through to the generic no-verdict message. Applied to all
three pipeline workflows (dev-agent.yml, qa-agent.yml,
principal-review.yml) since they share the identical
claude-code-action + id-token:write + pull_request pattern; scoped to
dev-agent.yml's revise mode only, since triage mode never checks out
a PR branch.

Closes #254
@github-actions

Copy link
Copy Markdown
Contributor

📱 iOS Build Status: PASSED

✅ iOS Simulator Build & Unit Tests - success
✅ Android Core Modules - success

iOS UI tests run in a separate, informational job and are not reflected above — check "iOS UI Tests (informational)" for those.

View run details

Copy link
Copy Markdown
Collaborator

Automated pipeline health check (2026-08-17): This PR needs a human look — I can't confidently diagnose why it's stuck.

Since this diff touches .github/workflows/** (a sensitive_paths entry in .github/agent-policy.yml), this routine isn't adding a label itself. Per this PR's own description it should land on risk:high / status:needs-human-merge once classified. Needs a human to either manually classify/route it or review and merge directly.


Generated by Claude Code

@libravault-xyz
libravault-xyz merged commit 35cb910 into dev Aug 18, 2026
8 checks passed
@libravault-xyz
libravault-xyz deleted the fix/agent-pipeline-workflow-drift-oidc branch August 18, 2026 05:30
libravault-xyz added a commit that referenced this pull request Aug 18, 2026
Reviewed as principal dev lead: this is the fix for #231 (guard-step crash silently mislabeling a PR), CI green (required checks). Rebased and manually resolved a real conflict against #255 (both touched the same 'Advance PR' step) — merged the two independent checks in sensible order: guard-crash check first, then PR_NUMBER assignment, then workflow-drift check, unchanged from there. Merging directly since this is a sensitive workflow-file path.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent pipeline silently no-ops on stale PR branches: workflow-file drift trips GitHub's OIDC validation, producing a misleading "no verdict" message

1 participant